home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2006 September / SAN CD 9-2006 CD-ROM 16.iso / pc / Software / Network Telescope Control / NTC-Setup.Exe / Source / ntc_server_config.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2006-03-24  |  25.6 KB  |  896 lines

  1. unit ntc_server_config;
  2. {
  3.     Copyright (C) 2004 - 2006 Andrew Sprott
  4.  
  5.     http://astronomy.crysania.co.uk
  6.     astro@trefach.co.uk
  7.  
  8.     This program is free software; you can redistribute it and/or
  9.     modify it under the terms of the GNU General Public License
  10.     as published by the Free Software Foundation; either version 2
  11.     of the License, or (at your option) any later version.
  12.  
  13.     This program is distributed in the hope that it will be useful,
  14.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16.     GNU General Public License for more details.
  17.  
  18.     You should have received a copy of the GNU General Public License
  19.     along with this program; if not, write to the Free Software
  20.     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. }
  22.  
  23. interface
  24.  
  25. uses
  26.     Windows,
  27.     Messages,
  28.     SysUtils,
  29.     Variants,
  30.     Classes,
  31.     Graphics,
  32.     Controls,
  33.     Forms,
  34.     Dialogs,
  35.     StdCtrls,
  36.     ExtCtrls,
  37.     inifiles,
  38.     Buttons,
  39.  
  40.     ntc_server_form,
  41.     ntc_server_comms,
  42.     ntc_server_object,
  43.     ntc_server_observer;
  44.  
  45. const
  46.     mount_eq=0;
  47.     mount_az=1;
  48.  
  49. type
  50.     Tscope_config = class(tform)
  51.         config_panel: TPanel;
  52.         model_group: TGroupBox;
  53.         model_label: TLabel;
  54.         model_list: TComboBox;
  55.         hp_group: TGroupBox;
  56.         switch_hpp_button: TButton;
  57.     bug_group: TGroupBox;
  58.     century_check: TCheckBox;
  59.     seconds_check: TCheckBox;
  60.     misc_group: TGroupBox;
  61.     make_inis: TBitBtn;
  62.     enable_scope_check: TCheckBox;
  63.         mount_group: TRadioGroup;
  64.     precision_label: TLabel;
  65.     binary_check: TCheckBox;
  66.  
  67.         { form handling }
  68.         procedure formcreate(
  69.             sender:tobject);
  70.  
  71.         procedure update_precision_label;
  72.  
  73.         { utilities }
  74.         function get_precision
  75.             :boolean;
  76.  
  77.         { configuration }
  78.         procedure load_settings;
  79.  
  80.         procedure save_settings;
  81.  
  82.         procedure write_escape_scopes;
  83.  
  84.         { events }
  85.         procedure FormShow(
  86.             Sender: TObject);
  87.  
  88.         procedure adjust;
  89.  
  90.         procedure check_activate(
  91.             Sender: TObject);
  92.  
  93.         procedure model_listChange(
  94.             Sender:TObject);
  95.  
  96.         procedure switch_hpp_buttonClick(
  97.             Sender:TObject);
  98.  
  99.         procedure make_inisClick(
  100.             Sender: TObject);
  101.  
  102.         procedure form_close_query(
  103.                     Sender: TObject;
  104.             var CanClose: Boolean);
  105.  
  106.         procedure enable_scope_checkClick(
  107.             Sender: TObject);
  108.  
  109.         procedure century_checkClick(
  110.             Sender: TObject);
  111.  
  112.         procedure seconds_checkClick(
  113.             Sender: TObject);
  114.  
  115.         procedure binary_checkClick(
  116.             Sender: TObject);
  117.  
  118.     private
  119.         { Private declarations }
  120.     public
  121.         { Public declarations }
  122.         { configuration }
  123.         dimensions:dimensions_record;
  124.         high_precision:boolean;
  125.         binary_mode:boolean;
  126.         { debugging }
  127.         scope_enabled:boolean;
  128.         century_bug:boolean;
  129.         seconds_bug:boolean;
  130.         scope_type:word;
  131.  
  132.         { events }
  133.         procedure check_visible_and_show_hide(
  134.             sender:tobject);
  135.             
  136.         procedure hide_form;
  137.         procedure show_form;
  138.     end;
  139.  
  140. var
  141.     scope_config: Tscope_config;
  142.  
  143. implementation
  144.  
  145. uses
  146.     ntc_server_network, ntc_server_focus, ntc_server_tracking;
  147.  
  148. {$R *.dfm}
  149.  
  150.     { -------------
  151.         form handling
  152.         ------------- }
  153.  
  154. procedure tscope_config.update_precision_label;
  155. begin
  156.     if scope_config.high_precision then
  157.         precision_label.caption:=high_precision_text
  158.     else
  159.         precision_label.caption:=low_precision_text;
  160. end;
  161.  
  162. procedure tscope_config.formcreate(
  163.     Sender:TObject);
  164. begin
  165.     scope_enabled:=true;
  166.     scope_type:=autostar_type;
  167.     binary_check.enabled:=false;
  168.     binary_mode:=false;
  169.     load_settings;
  170.     with scope_observer,current_object do
  171.         begin
  172.             update_precision_label;
  173.             case scope_type of
  174.                 lx200_type:
  175.                     begin
  176.                         if scope_config.high_precision then
  177.                             hp_group.visible:=true;
  178.                     end;
  179.                 autostar_type:
  180.                     begin
  181.                         if scope_config.high_precision then
  182.                             hp_group.visible:=true;
  183.                     end;
  184.                 celestron_type:
  185.                     begin
  186.                         if scope_config.high_precision then
  187.                             hp_group.visible:=true;
  188.                     end;
  189.             end;
  190.         end;
  191. end;
  192.  
  193.     { ---------
  194.         utilities
  195.         --------- }
  196.  
  197. function tscope_config.get_precision
  198.     :boolean;
  199. begin
  200.     result:=scope_config.high_precision;
  201. end;
  202.  
  203.     { ----------------------
  204.         configuration settings
  205.         ---------------------- }
  206.  
  207. procedure tscope_config.load_settings;
  208. begin
  209.     ini_file:=tinifile.create(application_path+'server.ini');
  210.     with ini_file do
  211.         begin
  212.             scope_enabled:=readbool('config','scope_enabled',true);
  213.             enable_scope_check.checked:=scope_enabled;
  214.             century_bug:=readbool('config','century_bug',false);
  215.             century_check.checked:=century_bug;
  216.             seconds_bug:=readbool('config','seconds_bug',false);
  217.             seconds_check.checked:=seconds_bug;
  218.             scope_type:=readinteger('config','scope_type',default_scope_type);
  219.             if (scope_type<first_scope_type) or (scope_type>last_scope_type) then
  220.                 scope_type:=default_scope_type;
  221.             model_list.itemindex:=scope_type-1;
  222.             binary_mode:=readbool('config','binary',false);
  223.             binary_check.enabled:=scope_type=celestron_type;
  224.             binary_check.checked:=binary_mode;
  225.             { form }
  226.             scope.get_dimensions(scope_config,@dimensions,'config',ini_file);
  227.             left:=dimensions.form_left;
  228.             top:=dimensions.form_top;
  229.             visible:=readbool('config','visible',false);
  230.         end;
  231.     ini_file.free;
  232. end;
  233.  
  234. procedure tscope_config.save_settings;
  235. begin
  236.     with ini_file do
  237.         begin
  238.             writebool('config','scope_enabled',scope_enabled);
  239.             writebool('config','century_bug',century_bug);
  240.             writebool('config','seconds_bug',seconds_bug);
  241.             writeinteger('config','scope_type',scope_type);
  242.             writebool('config','binary',binary_mode);
  243.             { form }
  244.             scope.find_vdu(scope_config,@dimensions);
  245.             scope.write_dimensions(@dimensions,left,top,'config',ini_file);
  246.             writebool('config','visible',visible);
  247.         end;
  248. end;
  249.  
  250. procedure tscope_config.write_escape_scopes;
  251. var
  252.     ini_file:tinifile;
  253. begin
  254.     ini_file:=tinifile.create(application_path+'lx200.ini');
  255.     with ini_file do
  256.         begin
  257.             writestring('switch_precision','write','#:U#');
  258.             writebool('switch_precision','append',false);
  259.             writebool('switch_precision','returns',false);
  260.  
  261.             writestring('query','write','#:GR#');
  262.             writebool('query','append',false);
  263.             writebool('query','returns',true);
  264.             writestring('query','object','$*$');
  265.  
  266.             writestring('stopped','write',':D#');
  267.             writebool('stopped','append',false);
  268.             writebool('stopped','returns',true);
  269.             writestring('stopped','valid','$valid=#$');
  270.  
  271.             writestring('get_ra','write','#:GR#');
  272.             writebool('get_ra','append',false);
  273.             writebool('get_ra','returns',true);
  274.             writestring('get_ra','high','$hms$');
  275.             writestring('get_ra','low','$hmt$');
  276.  
  277.             writestring('get_dec','write','#:GD#');
  278.             writebool('get_dec','append',false);
  279.             writebool('get_dec','returns',true);
  280.             writestring('get_dec','high','$dms$');
  281.             writestring('get_dec','low','$dm$');
  282.  
  283.             writestring('get_alt','write','#:GA#');
  284.             writebool('get_alt','append',false);
  285.             writebool('get_alt','returns',true);
  286.             writestring('get_alt','high','$dms$');
  287.             writestring('get_alt','low','$dm$');
  288.  
  289.             writestring('get_az','write','#:GZ#');
  290.             writebool('get_az','append',false);
  291.             writebool('get_az','returns',true);
  292.             writestring('get_az','high','$ddms$');
  293.             writestring('get_az','low','$ddmt$');
  294.  
  295.             writestring('set_ra','write','#:Sr');
  296.             writebool('set_ra','append',true);
  297.             writestring('set_ra','high','$hms$#');
  298.             writestring('set_ra','low','$hmt$#');
  299.             writebool('set_ra','returns',true);
  300.             writestring('set_ra','valid','$valid=1$');
  301.  
  302.             writestring('set_dec','write','#:Sd');
  303.             writebool('set_dec','append',true);
  304.             writestring('set_dec','high','$dms$#');
  305.             writestring('set_dec','low','$dm$#');
  306.             writebool('set_dec','returns',true);
  307.             writestring('set_dec','valid','$valid=1$');
  308.  
  309.             writestring('set_alt','write','#:Sa');
  310.             writebool('set_alt','append',true);
  311.             writestring('set_alt','high','$ams$#');
  312.             writestring('set_alt','low','$am$#');
  313.             writebool('set_alt','returns',true);
  314.             writestring('set_alt','valid','$valid=1$');
  315.  
  316.             writestring('set_az','write','#:Sz');
  317.             writebool('set_az','append',true);
  318.             writestring('set_az','high','$ddms$#');
  319.             writestring('set_az','low','$ddmt$#');
  320.             writebool('set_az','returns',false);
  321.  
  322.             writestring('slew_ra','write','#:MS#');
  323.             writebool('slew_ra','append',false);
  324.             writebool('slew_ra','returns',true);
  325.             writestring('slew_ra','valid','$valid=0$');
  326.  
  327.             writestring('slew_az','write','#:MA#');
  328.             writebool('slew_az','append',false);
  329.             writebool('slew_az','returns',true);
  330.             writestring('slew_az','valid','$valid=0$');
  331.  
  332.             writestring('sync','write','#:CM#');
  333.             writebool('sync','append',false);
  334.             writebool('sync','returns',true);
  335.             writestring('sync','object','$*$');
  336.  
  337.             writestring('speed_slew','write','#:RS#');
  338.             writebool('speed_slew','append',false);
  339.             writebool('speed_slew','returns',false);
  340.  
  341.             writestring('speed_move','write','#:RM#');
  342.             writebool('speed_move','append',false);
  343.             writebool('speed_move','returns',false);
  344.  
  345.             writestring('speed_guide','write','#:RG#');
  346.             writebool('speed_guide','append',false);
  347.             writebool('speed_guide','returns',false);
  348.  
  349.             writestring('speed_centre','write','#:RC#');
  350.             writebool('speed_centre','append',false);
  351.             writebool('speed_centre','returns',false);
  352.  
  353.             writestring('speed','write','#:Sw');
  354.             writebool('speed','append',true);
  355.             writestring('speed','speed','$[2-4]$#');
  356.             writebool('speed','returns',true);
  357.             writestring('speed','value','$*$');
  358.  
  359.             writestring('move_north','write','#:Mn#');
  360.             writebool('move_north','append',false);
  361.             writebool('move_north','returns',false);
  362.  
  363.             writestring('move_east','write','#:Me#');
  364.             writebool('move_east','append',false);
  365.             writebool('move_east','returns',false);
  366.  
  367.             writestring('move_south','write','#:Ms#');
  368.             writebool('move_south','append',false);
  369.             writebool('move_south','returns',false);
  370.  
  371.             writestring('move_west','write','#:Mw#');
  372.             writebool('move_west','append',false);
  373.             writebool('move_west','returns',false);
  374.  
  375.             writestring('stop_north','write','#:Qn#');
  376.             writebool('stop_north','append',false);
  377.             writebool('stop_north','returns',false);
  378.  
  379.             writestring('stop_east','write','#:Qe#');
  380.             writebool('stop_east','append',false);
  381.             writebool('stop_east','returns',false);
  382.  
  383.             writestring('stop_south','write','#:Qs#');
  384.             writebool('stop_south','append',false);
  385.             writebool('stop_south','returns',false);
  386.  
  387.             writestring('stop_west','write','#:Qw#');
  388.             writebool('stop_west','append',false);
  389.             writebool('stop_west','returns',false);
  390.  
  391.             writestring('stop_all','write','#:Q#');
  392.             writebool('stop_all','append',false);
  393.             writebool('stop_all','returns',false);
  394.  
  395.             writestring('stop_move','write','#:Q#:Qn#:Qs#:Qe#:Qw#');
  396.             writebool('stop_move','append',false);
  397.             writebool('stop_move','returns',false);
  398.  
  399.             writestring('focus_fast','write','#:FF#');
  400.             writebool('focus_fast','append',false);
  401.             writebool('focus_fast','returns',false);
  402.  
  403.             writestring('focus_slow','write','#:FS#');
  404.             writebool('focus_slow','append',false);
  405.             writebool('focus_slow','returns',false);
  406.  
  407.             writestring('focus_speed','write','#:F');
  408.             writebool('focus_speed','append',true);
  409.             writestring('focus_speed','speed','$[1-4]$#');
  410.             writebool('focus_speed','returns',false);
  411.  
  412.             writestring('focus_in','write','#:F+#');
  413.             writebool('focus_in','append',false);
  414.             writebool('focus_in','returns',false);
  415.  
  416.             writestring('focus_out','write','#:F-#');
  417.             writebool('focus_out','append',false);
  418.             writebool('focus_out','returns',false);
  419.  
  420.             writestring('focus_stop','write','#:FQ#');
  421.             writebool('focus_stop','append',false);
  422.             writebool('focus_stop','returns',false);
  423.  
  424.             writestring('tracking_increase','write','#:T+#');
  425.             writebool('tracking_increase','append',false);
  426.             writebool('tracking_increase','returns',false);
  427.  
  428.             writestring('tracking_decrease','write','#:T-#');
  429.             writebool('tracking_decrease','append',false);
  430.             writebool('tracking_decrease','returns',false);
  431.  
  432.             writestring('tracking_default','write','#:TQ#');
  433.             writebool('tracking_default','append',false);
  434.             writebool('tracking_default','returns',false);
  435.  
  436.             writestring('tracking_lunar','write','#:TL#');
  437.             writebool('tracking_lunar','append',false);
  438.             writebool('tracking_lunar','returns',false);
  439.         end;
  440.     ini_file.free;
  441.     ini_file:=tinifile.create(application_path+'autostar.ini');
  442.     with ini_file do
  443.         begin
  444.             writestring('switch_precision','write','#:U#');
  445.             writebool('switch_precision','append',false);
  446.             writebool('switch_precision','returns',false);
  447.  
  448.             writestring('query','write','#:GR#');
  449.             writebool('query','append',false);
  450.             writebool('query','returns',true);
  451.             writestring('query','object','$*$');
  452.  
  453.             writestring('stopped','write',':D#');
  454.             writebool('stopped','append',false);
  455.             writebool('stopped','returns',true);
  456.             writestring('stopped','valid','$valid!#$');
  457.  
  458.             writestring('get_ra','write','#:GR#');
  459.             writebool('get_ra','append',false);
  460.             writebool('get_ra','returns',true);
  461.             writestring('get_ra','high','$hms$');
  462.             writestring('get_ra','low','$hmt$');
  463.  
  464.             writestring('get_dec','write','#:GD#');
  465.             writebool('get_dec','append',false);
  466.             writebool('get_dec','returns',true);
  467.             writestring('get_dec','high','$dms$');
  468.             writestring('get_dec','low','$dm$');
  469.  
  470.             writestring('get_alt','write','#:GA#');
  471.             writebool('get_alt','append',false);
  472.             writebool('get_alt','returns',true);
  473.             writestring('get_alt','high','$dms$');
  474.             writestring('get_alt','low','$dm$');
  475.  
  476.             writestring('get_az','write','#:GZ#');
  477.             writebool('get_az','append',false);
  478.             writebool('get_az','returns',true);
  479.             writestring('get_az','high','$ddms$');
  480.             writestring('get_az','low','$ddmt$');
  481.  
  482.             writestring('set_ra','write','#:Sr');
  483.             writebool('set_ra','append',true);
  484.             writestring('set_ra','high','$hms$#');
  485.             writestring('set_ra','low','$hmt$#');
  486.             writebool('set_ra','returns',true);
  487.             writestring('set_ra','valid','$valid=1$');
  488.  
  489.             writestring('set_dec','write','#:Sd');
  490.             writebool('set_dec','append',true);
  491.             writestring('set_dec','high','$dms$#');
  492.             writestring('set_dec','low','$dm$#');
  493.             writebool('set_dec','returns',true);
  494.             writestring('set_dec','valid','$valid=1$');
  495.  
  496.             writestring('set_alt','write','#:Sa');
  497.             writebool('set_alt','append',true);
  498.             writestring('set_alt','high','$ams$#');
  499.             writestring('set_alt','low','$am$#');
  500.             writebool('set_alt','returns',true);
  501.             writestring('set_alt','valid','$valid=1$');
  502.  
  503.             writestring('set_az','write','#:Sz');
  504.             writebool('set_az','append',true);
  505.             writestring('set_az','high','$ddms$#');
  506.             writestring('set_az','low','$ddmt$#');
  507.             writebool('set_az','returns',false);
  508.  
  509.             writestring('slew_ra','write','#:MS#');
  510.             writebool('slew_ra','append',false);
  511.             writebool('slew_ra','returns',true);
  512.             writestring('slew_ra','valid','$valid=0$');
  513.  
  514.             writestring('slew_az','write','#:MA#');
  515.             writebool('slew_az','append',false);
  516.             writebool('slew_az','returns',true);
  517.             writestring('slew_az','valid','$valid=0$');
  518.  
  519.             writestring('sync','write','#:CM#');
  520.             writebool('sync','append',false);
  521.             writebool('sync','returns',true);
  522.             writestring('sync','object','$*$');
  523.  
  524.             writestring('speed_slew','write','#:RS#');
  525.             writebool('speed_slew','append',false);
  526.             writebool('speed_slew','returns',false);
  527.  
  528.             writestring('speed_move','write','#:RM#');
  529.             writebool('speed_move','append',false);
  530.             writebool('speed_move','returns',false);
  531.  
  532.             writestring('speed_guide','write','#:RG#');
  533.             writebool('speed_guide','append',false);
  534.             writebool('speed_guide','returns',false);
  535.  
  536.             writestring('speed_centre','write','#:RC#');
  537.             writebool('speed_centre','append',false);
  538.             writebool('speed_centre','returns',false);
  539.  
  540.             writestring('speed','write','#:Sw');
  541.             writebool('speed','append',true);
  542.             writestring('speed','speed','$[2-4]$#');
  543.             writebool('speed','returns',true);
  544.             writestring('speed','value','$*$');
  545.  
  546.             writestring('move_north','write','#:Mn#');
  547.             writebool('move_north','append',false);
  548.             writebool('move_north','returns',false);
  549.  
  550.             writestring('move_east','write','#:Me#');
  551.             writebool('move_east','append',false);
  552.             writebool('move_east','returns',false);
  553.  
  554.             writestring('move_south','write','#:Ms#');
  555.             writebool('move_south','append',false);
  556.             writebool('move_south','returns',false);
  557.  
  558.             writestring('move_west','write','#:Mw#');
  559.             writebool('move_west','append',false);
  560.             writebool('move_west','returns',false);
  561.  
  562.             writestring('stop_north','write','#:Qn#');
  563.             writebool('stop_north','append',false);
  564.             writebool('stop_north','returns',false);
  565.  
  566.             writestring('stop_east','write','#:Qe#');
  567.             writebool('stop_east','append',false);
  568.             writebool('stop_east','returns',false);
  569.  
  570.             writestring('stop_south','write','#:Qs#');
  571.             writebool('stop_south','append',false);
  572.             writebool('stop_south','returns',false);
  573.  
  574.             writestring('stop_west','write','#:Qw#');
  575.             writebool('stop_west','append',false);
  576.             writebool('stop_west','returns',false);
  577.  
  578.             writestring('stop_all','write','#:Q#');
  579.             writebool('stop_all','append',false);
  580.             writebool('stop_all','returns',false);
  581.  
  582.             writestring('stop_move','write','#:Q#:Qn#:Qs#:Qe#:Qw#');
  583.             writebool('stop_move','append',false);
  584.             writebool('stop_move','returns',false);
  585.  
  586.             writestring('focus_fast','write','#:FF#');
  587.             writebool('focus_fast','append',false);
  588.             writebool('focus_fast','returns',false);
  589.  
  590.             writestring('focus_slow','write','#:FS#');
  591.             writebool('focus_slow','append',false);
  592.             writebool('focus_slow','returns',false);
  593.  
  594.             writestring('focus_speed','write','#:F');
  595.             writebool('focus_speed','append',true);
  596.             writestring('focus_speed','speed','$[1-4]$#');
  597.             writebool('focus_speed','returns',false);
  598.  
  599.             writestring('focus_in','write','#:F+#');
  600.             writebool('focus_in','append',false);
  601.             writebool('focus_in','returns',false);
  602.  
  603.             writestring('focus_out','write','#:F-#');
  604.             writebool('focus_out','append',false);
  605.             writebool('focus_out','returns',false);
  606.  
  607.             writestring('focus_stop','write','#:FQ#');
  608.             writebool('focus_stop','append',false);
  609.             writebool('focus_stop','returns',false);
  610.  
  611.             writestring('tracking_increase','write','#:T+#');
  612.             writebool('tracking_increase','append',false);
  613.             writebool('tracking_increase','returns',false);
  614.  
  615.             writestring('tracking_decrease','write','#:T-#');
  616.             writebool('tracking_decrease','append',false);
  617.             writebool('tracking_decrease','returns',false);
  618.  
  619.             writestring('tracking_default','write','#:TQ#');
  620.             writebool('tracking_default','append',false);
  621.             writebool('tracking_default','returns',false);
  622.  
  623.             writestring('tracking_lunar','write','#:TL#');
  624.             writebool('tracking_lunar','append',false);
  625.             writebool('tracking_lunar','returns',false);
  626.         end;
  627.     ini_file:=tinifile.create(application_path+'celestron.ini');
  628.     with ini_file do
  629.         begin
  630.             writestring('query','write','?');
  631.             writebool('query','append',false);
  632.             writebool('query','returns',true);
  633.             writestring('query','valid','$valid=#$');
  634.  
  635.             writestring('stopped','write','L');
  636.             writebool('stopped','append',false);
  637.             writebool('stopped','returns',true);
  638.             writestring('stopped','valid','$valid=0#$');
  639.  
  640.             writestring('get_ra_dec','write','E');
  641.             writebool('get_ra_dec','append',false);
  642.             writebool('get_ra_dec','returns',true);
  643.             writestring('get_ra_dec','high','$ra_hex32$,$dec_hex32$#');
  644.             writestring('get_ra_dec','low','$ra_hex$,$dec_hex$#');
  645.  
  646.             writestring('get_az_alt','write','Z');
  647.             writebool('get_az_alt','append',false);
  648.             writebool('get_az_alt','returns',true);
  649.             writestring('get_az_alt','high','$az_hex32$,$alt_hex32$#');
  650.             writestring('get_az_alt','low','$az_hex$,$alt_hex$#');
  651.  
  652.             writestring('goto_ra_dec','write','R');
  653.             writebool('goto_ra_dec','append',true);
  654.             writestring('goto_ra_dec','high','$ra_hex32$,$dec_hex32$');
  655.             writestring('goto_ra_dec','low','$ra_hex$,$dec_hex$');
  656.             writebool('goto_ra_dec','returns',true);
  657.             writestring('goto_ra_dec','valid','$valid=#$');
  658.  
  659.             writestring('goto_az_alt','write','B');
  660.             writebool('goto_az_alt','append',true);
  661.             writestring('goto_az_alt','high','$az_hex32$,$alt_hex32$');
  662.             writestring('goto_az_alt','low','$az_hex$,$alt_hex$');
  663.             writebool('goto_az_alt','returns',true);
  664.             writestring('goto_az_alt','valid','$valid=#$');
  665.  
  666.             writestring('get_ra_dec_bin','write','E');
  667.             writebool('get_ra_dec_bin','append',false);
  668.             writebool('get_ra_dec_bin','returns',true);
  669.             writestring('get_ra_dec_bin','high','$ra_bin32$$dec_bin32$#');
  670.             writestring('get_ra_dec_bin','low','$ra_bin$$dec_bin$#');
  671.  
  672.             writestring('get_az_alt_bin','write','Z');
  673.             writebool('get_az_alt_bin','append',false);
  674.             writebool('get_az_alt_bin','returns',true);
  675.             writestring('get_az_alt_bin','high','$az_bin32$$alt_bin32$#');
  676.             writestring('get_az_alt_bin','low','$az_bin$$alt_bin$#');
  677.  
  678.             writestring('goto_az_alt_bin','write','R');
  679.             writebool('goto_az_alt_bin','append',true);
  680.             writestring('goto_az_alt_bin','high','$ra_bin32$$dec_bin32$');
  681.             writestring('goto_az_alt_bin','low','$ra_bin$$dec_bin$');
  682.             writebool('goto_az_alt_bin','returns',true);
  683.             writestring('goto_az_alt_bin','valid','$valid=#$');
  684.  
  685.             writestring('goto_az_alt_bin','write','B');
  686.             writebool('goto_az_alt_bin','append',true);
  687.             writestring('goto_az_alt_bin','high','$az_bin32$$alt_bin32$');
  688.             writestring('goto_az_alt_bin','low','$az_bin$$alt_bin$');
  689.             writebool('goto_az_alt_bin','returns',true);
  690.             writestring('goto_az_alt_bin','valid','$valid=#$');
  691.  
  692.             writestring('tracking_off','write','T0');
  693.             writebool('tracking_off','append',false);
  694.             writebool('tracking_off','returns',true);
  695.             writestring('tracking_off','valid','$valid=#$');
  696.  
  697.             writestring('tracking_az','write','T1');
  698.             writebool('tracking_az','append',false);
  699.             writebool('tracking_az','returns',true);
  700.             writestring('tracking_az','valid','$valid=#$');
  701.  
  702.             writestring('tracking_eq_north','write','T2');
  703.             writebool('tracking_eq_north','append',false);
  704.             writebool('tracking_eq_north','returns',true);
  705.             writestring('tracking_eq_north','valid','$valid=#$');
  706.  
  707.             writestring('tracking_eq_south','write','T3');
  708.             writebool('tracking_eq_south','append',false);
  709.             writebool('tracking_eq_south','returns',true);
  710.             writestring('tracking_eq_south','valid','$valid=#$');
  711.         end;
  712.     ini_file.free;
  713. end;
  714.  
  715.     { ------
  716.         events
  717.         ------ }
  718.  
  719. procedure tscope_config.FormShow(
  720.     Sender: TObject);
  721. begin
  722.     with dimensions do
  723.         begin
  724.             top:=form_top;
  725.             left:=form_left;
  726.         end;
  727.     with precision_label do
  728.         begin
  729.             width:=137;
  730.             update_precision_label;
  731.         end;
  732. end;
  733.  
  734. procedure tscope_config.adjust;
  735. begin
  736.     with dimensions do
  737.         begin
  738.             form_top:=trunc(form_top/last_screen_height*current_height);
  739.             form_left:=trunc(form_left/last_screen_width*current_width);
  740.         end;
  741.     if visible then
  742.         show;
  743. end;
  744.  
  745. procedure tscope_config.check_visible_and_show_hide(
  746.     sender:tobject);
  747. begin
  748.     if visible then
  749.         hide_form
  750.     else
  751.         show_form;
  752.     scope.show_hide(sender,visible);
  753. end;
  754.  
  755. procedure tscope_config.hide_form;
  756. begin
  757.     with dimensions do
  758.         begin
  759.             form_top:=top;
  760.             form_left:=left;
  761.         end;
  762.     Visible:=false;
  763. end;
  764.  
  765. procedure tscope_config.show_form;
  766. begin
  767.     Visible:=true;
  768. end;
  769.  
  770. procedure Tscope_config.check_activate(
  771.     Sender: TObject);
  772. begin
  773.     scope.form_activate(scope_config,@dimensions);
  774. end;
  775.  
  776. procedure Tscope_config.form_close_query(
  777.             Sender: TObject;
  778.     var CanClose: Boolean);
  779. begin
  780.     canclose:=false;
  781.     visible:=false;
  782.     with dimensions do
  783.         begin
  784.             form_top:=top;
  785.             form_left:=left;
  786.         end;
  787. end;
  788.  
  789. procedure tscope_config.model_listChange(
  790.     Sender:TObject);
  791. var
  792.     toggle:boolean;
  793. begin
  794.     scope_comms.command_list.free;
  795.     with scope_observer do
  796.          case model_list.itemindex+1 of
  797.         lx200_type:
  798.             begin
  799.                 scope_type:=lx200_type;
  800.                 observatory_group.visible:=true;
  801.                 if scope_config.high_precision then
  802.                     hp_group.visible:=true;
  803.                 toggle:=true;
  804.             end;
  805.         autostar_type:
  806.             begin
  807.                 scope_type:=autostar_type;
  808.                 observatory_group.visible:=true;
  809.                 if scope_config.high_precision then
  810.                     hp_group.visible:=true;
  811.                 toggle:=true;
  812.             end;
  813.         celestron_type:
  814.             begin
  815.                 scope_type:=celestron_type;
  816.                 observatory_group.Visible:=true;
  817.                 if scope_config.high_precision then
  818.                     hp_group.visible:=true;
  819.                 toggle:=false;
  820.             end;
  821.         else
  822.             begin
  823.                 observatory_group.visible:=true;
  824.                 if scope_config.high_precision then
  825.                     hp_group.visible:=true;
  826.                 toggle:=true;
  827.             end;
  828.     end;
  829.     scope_focus.flip_buttons(toggle);
  830.     scope_tracking.flip_buttons(toggle);
  831.     scope_comms.read_escape_scopes;
  832. end;
  833.  
  834. procedure tscope_config.switch_hpp_buttonClick(
  835.     Sender:TObject);
  836. begin
  837.     if scope_enabled then
  838.         begin
  839.             if scope_type=celestron_type then
  840.                 begin
  841.                     high_precision:=not high_precision;
  842.                     update_precision_label;
  843.                 end
  844.             else if scope_network.send_message_check('switch_precision')>=[exit_ok] then
  845.                 begin
  846.                     high_precision:=get_precision;
  847.                     update_precision_label;
  848.                 end
  849.             else
  850.                 precision_label.caption:='Precision unknown';
  851.         end
  852.     else
  853.         begin
  854.             high_precision:=not high_precision;
  855.             update_precision_label;
  856.         end;
  857. end;
  858.  
  859. procedure Tscope_config.make_inisClick(
  860.     Sender: TObject);
  861. begin
  862.     write_escape_scopes;
  863.     with scope_comms do
  864.         begin
  865.             if command_list<>nil then
  866.                 command_list.free;
  867.             read_escape_scopes;
  868.         end;
  869. end;
  870.  
  871. procedure Tscope_config.enable_scope_checkClick(
  872.     Sender: TObject);
  873. begin
  874.     scope_enabled:=enable_scope_check.checked;
  875. end;
  876.  
  877. procedure Tscope_config.century_checkClick(
  878.     Sender: TObject);
  879. begin
  880.     century_bug:=century_check.checked;
  881. end;
  882.  
  883. procedure Tscope_config.seconds_checkClick(
  884.     Sender: TObject);
  885. begin
  886.     seconds_bug:=seconds_check.checked;
  887. end;
  888.  
  889. procedure Tscope_config.binary_checkClick(
  890.     Sender: TObject);
  891. begin
  892.     binary_mode:=binary_check.Checked;
  893. end;
  894.  
  895. end.
  896.